%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/conditions/archived-forum-inherited-messages.defer-5"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 9, 10, 72, 73, 11, 13, 28<br />2: PgSelect[8]<br />3: PgSelectRows[14]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 11, 28<br /><br />ROOT __Item{1}ᐸ14ᐳ[15]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 16, 11, 28<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[16]<br />1: <br />ᐳ: 17, 19, 25<br />2: PgSelect[20]<br />3: Connection[24]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 24, 11, 19, 25, 28, 20<br /><br />ROOT Connection{2}ᐸ20ᐳ[24]<br />1: ConnectionItems[29], PgSelect[35]<br />ᐳ: 34, 43, 44, 55<br />2: PgSelectRows[37]<br />ᐳ: 36, 38, 39"):::bucket
    Bucket6("Bucket 6 (listItem)<br />Deps: 55, 11<br /><br />ROOT __Item{6}ᐸ29ᐳ[40]"):::bucket
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 41, 11<br /><br />ROOT PgSelectSingle{6}ᐸmessagesᐳ[41]<br />1: <br />ᐳ: 45, 47<br />2: PgSelect[48]<br />3: PgSelectRows[53]<br />ᐳ: First[52], PgSelectSingle[54]"):::bucket
    Bucket8("Bucket 8 (nullableBoundary)<br />Deps: 42, 41, 11, 56<br /><br />ROOT Edge{6}[42]"):::bucket
    Bucket9("Bucket 9 (defer)<br />Deps: 42, 56"):::bucket
    Bucket10("Bucket 10 (nullableBoundary)<br />Deps: 41, 11<br /><br />ROOT PgSelectSingle{6}ᐸmessagesᐳ[41]<br />1: <br />ᐳ: 57, 59<br />2: PgSelect[60]<br />3: PgSelectRows[65]<br />ᐳ: First[64], PgSelectSingle[66]"):::bucket
    Bucket11("Bucket 11 (nullableBoundary)<br />Deps: 54<br /><br />ROOT PgSelectSingle{7}ᐸusersᐳ[54]"):::bucket
    Bucket12("Bucket 12 (nullableBoundary)<br />Deps: 66<br /><br />ROOT PgSelectSingle{10}ᐸusersᐳ[66]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket6
    Bucket6 --> Bucket7 & Bucket8
    Bucket7 --> Bucket11
    Bucket8 --> Bucket9 & Bucket10
    Bucket10 --> Bucket12

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸforumsᐳ<br />More deps:<br />- Object[11]"]]:::plan
    Lambda13{{"Lambda[13∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'EXCLUSIVELY' ]ᐳ[72]"}}:::plan
    Lambda13 --> PgSelect8
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 5"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    PgSelectRows14[["PgSelectRows[14∈0] ➊"]]:::plan
    PgSelect8 --> PgSelectRows14
    Lambda28{{"Lambda[28∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />Dependents: 2<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[73]"}}:::plan
    __Item15[/"__Item[15∈1]<br />ᐸ14ᐳ"\]:::itemplan
    PgSelectRows14 ==> __Item15
    PgSelectSingle16{{"PgSelectSingle[16∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item15 --> PgSelectSingle16
    PgSelect20[["PgSelect[20∈2]<br />ᐸmessages+1ᐳ<br />More deps:<br />- Object[11]<br />- Lambda[28]"]]:::plan
    PgClassExpression19{{"PgClassExpression[19∈2]<br />ᐸ__forums__.”id”ᐳ"}}:::plan
    PgClassExpression25{{"PgClassExpression[25∈2]<br />ᐸ__forums__...chived_at”ᐳ"}}:::plan
    PgClassExpression19 & PgClassExpression25 --> PgSelect20
    PgClassExpression17{{"PgClassExpression[17∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle16 --> PgClassExpression17
    PgSelectSingle16 --> PgClassExpression19
    Connection24[["Connection[24∈2]<br />ᐸ20ᐳ"]]:::plan
    PgSelect20 --> Connection24
    PgSelectSingle16 --> PgClassExpression25
    PgSelect35[["PgSelect[35∈3]<br />ᐸmessages(aggregate)ᐳ<br />More deps:<br />- Object[11]<br />- Lambda[28]"]]:::plan
    PgClassExpression19 & PgClassExpression25 --> PgSelect35
    ConnectionItems29[["ConnectionItems[29∈3]"]]:::plan
    Connection24 --> ConnectionItems29
    PageInfo34{{"PageInfo[34∈3]"}}:::plan
    Connection24 --> PageInfo34
    First36{{"First[36∈3]"}}:::plan
    PgSelectRows37[["PgSelectRows[37∈3]"]]:::plan
    PgSelectRows37 --> First36
    PgSelect35 --> PgSelectRows37
    PgSelectSingle38{{"PgSelectSingle[38∈3]<br />ᐸmessagesᐳ"}}:::plan
    First36 --> PgSelectSingle38
    PgClassExpression39{{"PgClassExpression[39∈3]<br />ᐸcount(*)ᐳ"}}:::plan
    PgSelectSingle38 --> PgClassExpression39
    Access43{{"Access[43∈3]<br />ᐸ24.hasNextPageᐳ"}}:::plan
    PageInfo34 o--o Access43
    Access44{{"Access[44∈3]<br />ᐸ24.hasPreviousPageᐳ"}}:::plan
    Access43 o--o Access44
    Access55{{"Access[55∈3]<br />ᐸ20.cursorDetailsᐳ"}}:::plan
    PgSelect20 --> Access55
    Edge42{{"Edge[42∈6]"}}:::plan
    __Item40[/"__Item[40∈6]<br />ᐸ29ᐳ"\]:::itemplan
    PgCursor56{{"PgCursor[56∈6]"}}:::plan
    __Item40 & PgCursor56 --> Edge42
    __Item40 & Access55 --> PgCursor56
    ConnectionItems29 ==> __Item40
    PgSelectSingle41{{"PgSelectSingle[41∈6]<br />ᐸmessagesᐳ"}}:::plan
    __Item40 --> PgSelectSingle41
    PgSelect48[["PgSelect[48∈7]<br />ᐸusersᐳ<br />More deps:<br />- Object[11]"]]:::plan
    PgClassExpression47{{"PgClassExpression[47∈7]<br />ᐸ__messages...author_id”ᐳ"}}:::plan
    PgClassExpression47 --> PgSelect48
    PgClassExpression45{{"PgClassExpression[45∈7]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle41 --> PgClassExpression45
    PgSelectSingle41 --> PgClassExpression47
    First52{{"First[52∈7]"}}:::plan
    PgSelectRows53[["PgSelectRows[53∈7]"]]:::plan
    PgSelectRows53 --> First52
    PgSelect48 --> PgSelectRows53
    PgSelectSingle54{{"PgSelectSingle[54∈7]<br />ᐸusersᐳ"}}:::plan
    First52 --> PgSelectSingle54
    PgSelect60[["PgSelect[60∈10]<br />ᐸusersᐳ<br />More deps:<br />- Object[11]"]]:::plan
    PgClassExpression59{{"PgClassExpression[59∈10]<br />ᐸ__messages...author_id”ᐳ"}}:::plan
    PgClassExpression59 --> PgSelect60
    PgClassExpression57{{"PgClassExpression[57∈10]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgClassExpression45 o--o PgClassExpression57
    PgSelectSingle41 --> PgClassExpression59
    First64{{"First[64∈10]"}}:::plan
    PgSelectRows65[["PgSelectRows[65∈10]"]]:::plan
    PgSelectRows65 --> First64
    PgSelect60 --> PgSelectRows65
    PgSelectSingle66{{"PgSelectSingle[66∈10]<br />ᐸusersᐳ"}}:::plan
    First64 --> PgSelectSingle66
    PgClassExpression58{{"PgClassExpression[58∈11]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle54 --> PgClassExpression58
    PgClassExpression67{{"PgClassExpression[67∈11]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression58 o--o PgClassExpression67
    PgClassExpression68{{"PgClassExpression[68∈12]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle66 --> PgClassExpression68
    PgClassExpression69{{"PgClassExpression[69∈12]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression68 o--o PgClassExpression69

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Lambda13,PgSelectRows14,Lambda28 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item15,PgSelectSingle16 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression17,PgClassExpression19,PgSelect20,Connection24,PgClassExpression25 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,ConnectionItems29,PageInfo34,PgSelect35,First36,PgSelectRows37,PgSelectSingle38,PgClassExpression39,Access43,Access44,Access55 bucket3
    classDef bucket6 stroke:#ff1493
    class Bucket6,__Item40,PgSelectSingle41,Edge42,PgCursor56 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,PgClassExpression45,PgClassExpression47,PgSelect48,First52,PgSelectRows53,PgSelectSingle54 bucket7
    classDef bucket8 stroke:#dda0dd
    class Bucket8 bucket8
    classDef bucket9 stroke:#ff0000
    class Bucket9 bucket9
    classDef bucket10 stroke:#ffff00
    class Bucket10,PgClassExpression57,PgClassExpression59,PgSelect60,First64,PgSelectRows65,PgSelectSingle66 bucket10
    classDef bucket11 stroke:#00ffff
    class Bucket11,PgClassExpression58,PgClassExpression67 bucket11
    classDef bucket12 stroke:#4169e1
    class Bucket12,PgClassExpression68,PgClassExpression69 bucket12

